<template>
	<view class="beijingse mainpadding">
		<view class="">
			<!-- 订单状态 -->
			<view class="bigtext" v-if="dataAll.state==0">等待商家处理</view>
			<view class="bigtext" v-if="dataAll.state==1 && dataAll.type==1">等待买家寄回</view>
			<view class="bigtext" v-if="dataAll.state==6 && dataAll.type==1">等待商家确认收货</view>
			<view class="bigtext" v-if="dataAll.state==7">等待卖家换货</view>
			<view class="bigtext" v-if="dataAll.state==4 || dataAll.type==0 && dataAll.state==1">换货完成</view>
			<view class="bigtext" v-if="dataAll.state==2">卖家拒绝换货</view>
		</view>
		<!--订单时间状态  -->
		<view class="margin_top1">
			<view class="strongtext " v-if="dataAll.state==0">您已发起换货申请等待商家审核！</view>
			<view class="strongtext " v-if="dataAll.state==7">商家正在处理中~</view>
			<view class="strongtext " v-if="dataAll.state==1 && dataAll.type==1">卖家已同意您的申请请将商品寄回！</view>
			<view class="strongtext " v-if="dataAll.state==6 && dataAll.type==1">商家确认收货会将您的金额退回！</view>
			<view class="strongtext " v-if="dataAll.state==4 || dataAll.type==0 && dataAll.state==1">您的金额已原路退回，请注意查收！</view>
		</view>
		<!-- 寄回地址 -->
		<view class="mainpadding ffffff radius margin_top" v-if="dataAll.state==1 && dataAll.type==1">
			<view class="titletext">寄回地址</view>
			<view class="flexleft margin_top2">
				<view class="strongtext margin_right3">{{dataAll.shopConfig.returnName}}</view>
				<view class="strongtext">{{dataAll.shopConfig.returnPhoneNum}}</view>
			</view>
			<view class="huisetext margin_top2">{{dataAll.shopConfig.returnAddr}}</view>
		</view>
		<!-- 换货金额 -->
		<!-- <view class="mainpadding ffffff radius margin_top flexbetween">
			<view class="titletext">换货金额</view>
			<view class="qianshu">￥{{dataAll.price}}</view>
		</view> -->
		<!-- 快递单号 -->
		<view class="mainpadding ffffff radius margin_top" v-if="dataAll.state==6">
			<view class="flexbetween">
				<view class="titletext">快递公司</view>
				<view class="notitletext">{{dataAll.express_name}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="titletext">快递单号</view>
				<view class="notitletext">{{dataAll.express_no}}</view>
			</view>
		</view>
		<!-- 商品 -->
		<view class="ffffff mainpadding radius margin_top">
			<!-- 退货商品 -->
			<view class="flexleft">
				<view class="haungfz margin_right1"></view>
				<view class="titletext margin_right2">{{dataAll.shop.name}}</view>
				<view class="righticon"></view>
			</view>
			<view class=" xiahuax margin_top">
				<view class="flexbetween">
					<view class="shilitu">
						<image :src="dataAll.goods.image_text" mode=""></image>
					</view>
					<view class="" style="width: 74%;">
						<view class="ershib yhxiank">{{dataAll.goods.title}}</view>
						<view class="ershib margin_top1 yhxiank">{{dataAll.goods.difference}}</view>
						<view class="flexbetween margin_top1">
							<view class="qianshu">¥{{dataAll.goods.price}}</view>
							<view class="shuliang">*{{dataAll.goods.number}}</view>
						</view>
					</view>
				</view>
				<!-- <view class="flexright margin_top">
					<view class="huisebtn margin_right3" v-if="dataAll.state==2"
						@click="tzsqtk(dataAll.goods.id,dataAll.goods.order_id)">再次申请</view>
					<view class="huangsebtn" v-if="dataAll.state==2" @click="suresh">确认收货</view>
				</view> -->
			</view>
		</view>
		<!-- 商品详情 -->
		<view class="paddingbom">
			<view class="ffffff mainpadding radius margin_top ">
				<view class="flexbetween margin_top">
					<view class="ershil">订单编号</view>
					<view class="huisetext">347258934752</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil">换货申请时间</view>
					<view class="huisetext">{{dataAll.createtime_text}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil">换货原因</view>
					<view class="huisetext">{{dataAll.refund_content}}</view>
				</view>
				<view class="flexbetween margin_top" >
					<view class="ershil">换货金额</view>
					<view class="huisetext">￥{{dataAll.price}}</view>
				</view>
				<view class="flexbetween margin_top" v-if="dataAll.state==1">
					<view class="ershil">商家同意时间</view>
					<view class="huisetext">{{dataAll.createtime_text}}</view>
				</view>
				<view class="flexbetween margin_top" v-if="dataAll.state==2">
					<view class="ershil">商家拒绝时间</view>
					<view class="huisetext">{{dataAll.createtime_text}}</view>
				</view>
				<view class="flexbetween margin_top" v-if="dataAll.state==2">
					<view class="ershil">商家拒绝理由</view>
					<view class="huisetext">{{dataAll.refuse_content}}</view>
				</view>
			</view>
		</view>
		<!-- 固定底部 -->
		<view class="gudingdb ffffff">
			<view class="flexright">
				<view class="huisebtn margin_right3" v-if="dataAll.state==0 || dataAll.state==1" @click="cancelsq">取消申请</view>
				<view class="huangsebtn" v-if="dataAll.state==1 && dataAll.type==1" @click="tztxdh">填写单号</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid:"",
				dataAll:{}
			}
		},
		onLoad(options) {
			this.listid = options.id
		},
		onShow() {
			this.init()
		},
	
		methods: {
			init() {
				httpRequest.request('/api/order/getRefundInfo', 'POST', {
					id:this.listid
				}, false, false, true).then(res => {
					this.dataAll = res.data
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			// 确认收货
			suresh() {
				httpRequest.modal('提示', '请再次确认', true, (res) => {
					if (res) {
						httpRequest.request('/api/order/confirmOrder', 'POST', {
							id: this.listid,
						}, false, false, true).then(res => {
							httpRequest.toast(res.msg);
							if (res.code == 1) {
								this.init()
							}
						}).catch(err => {
							httpRequest.toast(err.msg);
						})
					}
				})
			},
			cancelsq(){
				httpRequest.modal('提示', '确定取消当前申请吗？', true, (res) => {
					if (res) {
						httpRequest.request('/api/order/getRefundInfo', 'POST', {
							id:this.listid
						}, false, false, true).then(res => {
							this.dataAll = res.data
						}).catch(err => {
							httpRequest.toast(err.msg);
						})
					}
				})
				
			},
			// 跳转申请换货
			tzsqtk(id,order_id) {
				let data = {
					listid:id,
					order_id:order_id
				}
				uni.navigateTo({
					url: '/pages/mypage/shenqtk?msg=' + encodeURIComponent(JSON.stringify(data))
				})
			},
			// 跳转立即评价
			tzfbpj() {
				uni.navigateTo({
					url: '/pages/mypage/fabiaoqj'
				})
			},
			// 跳转填写单号
			tztxdh() {
				uni.navigateTo({
					url: '/pages/mypage/tianxdh?id=' + this.listid
				})
			},
			// 跳转查看物流
			tzckwl() {
				uni.navigateTo({
					url: '/pages/mypage/wuliuxq'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.xzqianshu {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FAB536;
	}

	.huangsebtn {
		border: 2rpx solid #FAB536;
		width: 170rpx;
		height: 67rpx;
		display: flex;
		border-radius: 120rpx;
		align-items: center;
		justify-content: center;
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FAB536;
	}

	.huisebtn {
		border: 2rpx solid #666666;
		width: 170rpx;
		height: 67rpx;
		display: flex;
		border-radius: 120rpx;
		align-items: center;
		justify-content: center;
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.shuliang {
		font-size: 26rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #999999;
	}

	.ershib {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.shilitu {
		width: 134rpx;
		height: 128rpx;
		border-radius: 14rpx;

		image {
			width: 100%;
			height: 100%;
			border-radius: 14rpx;
		}
	}

	.qianshu {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FAB536;
	}

	.huisetext {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}
	.yhxiank {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.paddingbom{
		padding-bottom: 200rpx;
	}
</style>
